<?php

class Cookie {
	protected $_config;
	protected static $_instance = null;

	public static function getInstance() {
		if (null === self::$_instance) {
			self::$_instance = new self();
		}
		return self::$_instance;
	}

	private function __construct() {
		
	}

	public function get($key) {
		return isset($_COOKIE[$key]) ? $_COOKIE[$key] : null;
	}

	public function set($key, $value, $expire = 0) {
		$expire = $expire ? NOW + $expire : 0;
		return setcookie($key, $value, $expire, '', '', false, true);
	}

	public function has($key) {
		return isset($_COOKIE[$key]);
	}

	public function del($key) {
		return $this->set($key, '', -3600);
	}

	public function __set($key, $value) {
		return $this->set($key, $value);
	}

	public function __get($key) {
		return $this->get($key);
	}

	public function __isset($key) {
		return $this->has($key);
	} 

	public function __unset($key) {
		return $this->del($key);
	}
}